<? 
	$title="Edit category"; 
	$pageid="5";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	
	if(isset($_POST['btnsubmit']))
	{
		
		$currency=$_POST['currency'];
		$rate=$_POST['rate'];
	
		$get=mysql_query("select * from os_currency_code where id=$currency")or die(mysql_error());
		
		$currency_code=mysql_result($get,0,"currency_code");
		$country=mysql_result($get,0,"country");
		
		
		mysql_query("insert into os_currency (currency_code,country,rate)values('$currency_code','$country','$rate')")or die(mysql_error());
		header("Location:currency_setting.php?action=1");
	}
	
	require("required/header.php");
	checkAccess("allow_system_management",1);
	
	
	

		

	
	
?>
<table width="95%" cellpadding="2" cellspacing="1">
	
	<td valign="top">
	<table width="584">
	<tr>
		<td colspan="4"><font class="title">Edit Currency</font></td>
	</tr>
	<script type="text/javascript" src="required/js/calendarDateInput.js"></script>	
	<script language="JavaScript" type="text/javascript" src="wysiwyg.js">
				</script>	
	<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="frm" onSubmit="return frmValidate(this)">
	
	<tr>
		<td>Currency</td><td>:</td>
        <td>
        	<select name="currency">
            	<?
					$get_currency=mysql_query("select * from os_currency_code where currency_code<>'MYR' order by country asc ");
					
					while($c=mysql_fetch_array($get_currency,MYSQL_ASSOC))
					{
						
				?>
                <option value="<?= $c['id'] ?>"><?= $c['country'] ?> ( <?= $c['currency_code'] ?> )</option>
                
                <? } ?>
            </select>       	
        </td>
	</tr>
	<tr valign="top">
		<td>Rate</td><td>:</td><td>
		
		<input type="text" size="10" maxlength="10" class="text" name="rate" value='' /></td>
	</tr>
    
	
	
	<tr>
		<td colspan="3" align="center"><br>
        <input type="submit" value="Add" class="button" name="btnsubmit">  
        <input type="button" value="Back" class="button" onclick="window.open('currency_setting.php','_self')"><br><br>
      	</td>
	</tr>
	</form>
	</table></td>
			
</table>
<?  require("required/footer.php"); ?>

